'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 消耗品道具
 * @author sundbcn@gmail.com (sun debing)
 */

var mongoose = require('mongoose');
var _ = require('lodash');
var itemUtil = require('../../util/itemUtil');
var genEquipService = require('../../services/genEquipService');
var dataApi = require('../../libs/dataApi');

/**
 * 消耗品——>新增消耗品道具分类
 * @type {mongoose}
 */
var bagConsumeSchema = new mongoose.Schema({
    // 材料id
    consume_id: {
        type: Number,
        required: true,
        index: true
    },

    // 材料类型
    consume_type: {
        type: Number,
        required: true
    },

    // 叠加个数
    stack_num: {
        type: Number,
        default: 1
    }
});

/**
 * 获取消耗品类型
 * @return {[type]} [description]
 */
bagConsumeSchema.methods.getType = function () {
    return this.consume_type;
};

/**
 * 获取消耗品叠加个数
 * @return {[type]} [description]
 */
bagConsumeSchema.methods.getStackNum = function () {
    return this.stack_num;
};

/**
 * 获取消耗品id
 * @return {[type]} [description]
 */
bagConsumeSchema.methods.getId = function () {
    return this.consume_id;
};

/**
 * 添加叠加的数量
 */
bagConsumeSchema.methods.addStackNum = function () {
    this.stack_num++;
};

/**
 * 减少叠加的数量
 */
bagConsumeSchema.methods.subStackNum = function () {
    this.stack_num--;
};

if (!bagConsumeSchema.options.toJSON) {
    bagConsumeSchema.options.toJSON = {};
}
/* jshint unused:false */
bagConsumeSchema.options.toJSON.transform = function (doc, ret) {
    delete ret._id;
};

module.exports = bagConsumeSchema;
